const PREFIX = 'main_'
const MainActionType = {
  change_screen: PREFIX + 'change_screen',
  set_info: PREFIX + 'set_info',
  toggle_re_connect: PREFIX + 'toggle_re_connect',
  toggle_quit_pc: PREFIX + 'toggle_quit_pc',
  set_materials: PREFIX + 'set_materials',
  set_teachers: PREFIX + 'set_teachers',
  toggle_show_wait: PREFIX + 'toggle_show_wait',
  toggle_global_image: `${PREFIX}toggle_global_image`,
  set_global_token: `${PREFIX}set_global_token`
}

function setGlobalToken(token) {
  return {
    type: MainActionType.set_global_token,
    payload: { token }
  }
}

function toggleGlobalBigImage({ url }) {
  return {
    type: MainActionType.toggle_global_image,
    payload: { url }
  }
}

const toggleShowWait = (show) => {
  return {
    type: MainActionType.toggle_show_wait,
    showWait: show
  }
}

const setTeachers = (ts) => {
  return {
    type: MainActionType.set_teachers,
    teachers: ts
  }
}

const setMaterials = (materials) => {
  return {
    type: MainActionType.set_materials,
    materials: materials
  }
}
const setInfoData = (info) => {
  return {
    type: MainActionType.set_info,
    info: info
  }
}

const changeScreen = (screen) => {
  return {
    type: MainActionType.change_screen,
    screen: screen
  }
}

const toggleReconnect = (connect) => {
  return {
    type: MainActionType.toggle_re_connect,
    connect: connect
  }
}

const toggleQuitPc = (quit) => {
  return {
    type: MainActionType.toggle_quit_pc,
    quit: quit
  }
}

module.exports = {
  changeScreen,
  MainActionType,
  setInfoData,
  toggleReconnect,
  toggleQuitPc,
  setMaterials,
  setTeachers,
  toggleShowWait,
  toggleGlobalBigImage,
  setGlobalToken
}
